import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:wkweb/entities/article_list.dart';
import 'package:wkweb/util/utils.dart';

class ListItem extends StatelessWidget {
  final Datas data;

  const ListItem(this.data, {Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    ThemeData themeData = Theme.of(context);
    return Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Expanded(
            child: Padding(
                padding: EdgeInsets.only(left: 10, top: 10, bottom: 10),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Padding(
                      padding: EdgeInsets.only(bottom: 10),
                      child: Text(
                        "${Utils.processSpecial(data.title)}",
                        maxLines: 2,
                        textAlign: TextAlign.start,
                        style: TextStyle(
                            fontSize: 16, fontWeight: FontWeight.normal),
                      ),
                    ),
                    Row(
                      children: [
                        Expanded(
                            child: Text(
                                DateUtil.formatDateMs(data.publishTime ?? 0,
                                    format: DateFormats.y_mo_d),
                                style: TextStyle(
                                    fontSize: 14, color: themeData.hintColor))),
                        Text("${data.zan}点赞",
                            style: TextStyle(
                                fontSize: 12, color: themeData.hintColor))
                      ],
                    )
                  ],
                ))),
        Padding(
          padding: EdgeInsets.all(10),
          child: ClipRRect(
            borderRadius: BorderRadius.circular(10),
            child: Image.asset("assets/images/${(data.id ?? 0) % 4 + 1}.jpeg",
                cacheWidth: 60, cacheHeight: 60, width: 60, height: 60),
          ),
        )
      ],
    );
  }
}
